package com.zhouzhou.fastjava.criteria;

import com.zhouzhou.fastjava.provider.UserIdProvider;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;

public class ShiroUserIdProvider implements UserIdProvider {

    @Override
    public String getUserId() {
        try {
            Subject subject = SecurityUtils.getSubject();
            return subject.getPrincipal().toString();
        } catch (Exception e) {
            return null;
        }
    }

}
